package com.linewell.system.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
/**
 * 对应的数据库：SYS_USERS
 */
@Entity
@Table(name="SYS_USERS")
@DynamicInsert(true)
@DynamicUpdate(true)
public class SysUsers implements Serializable {

	private static final long serialVersionUID = -2001362304673568065L;
	
	private Integer userId;
//	private Integer roleId;		//角色编号
	private SysRoles sysRoles;
//	private Integer depId;
	private SysDepartment sysDepartment;
	private String userName;
	private Integer sex;
	private String phone;
	private String photo;
	private String loginName;		//登录名
	private String password;
	private Date createTime;
	private Date lastLoginTime;		//最近登入
	private String loginIp;
	private Byte status;
	
	@Id
	@Column(name = "USER_ID",nullable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)		//自增长
	public Integer getUserId() {
		return userId;
	}
	public void setUserId(Integer userId) {
		this.userId = userId;
	}
	
	@ManyToOne(targetEntity = SysRoles.class)
	@JoinColumn(name = "ROLE_ID")
	public SysRoles getSysRoles() {
		return sysRoles;
	}
	public void setSysRoles(SysRoles sysRoles) {
		this.sysRoles = sysRoles;
	}
	
	
	@ManyToOne(targetEntity = SysDepartment.class)
	@JoinColumn(name = "DEP_ID")
	public SysDepartment getSysDepartment() {
		return sysDepartment;
	}
	public void setSysDepartment(SysDepartment sysDepartment) {
		this.sysDepartment = sysDepartment;
	}
	
	@Column(name ="PHONE")
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	@Column(name = "USER_NAME",nullable = false)
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	@Column(name = "SEX",columnDefinition = "tinyint default 1")
	public Integer getSex() {
		return sex;
	}
	public void setSex(Integer sex) {
		this.sex = sex;
	}
	@Column(name = "PHOTO")
	public String getPhoto() {
		return photo;
	}
	public void setPhoto(String photo) {
		this.photo = photo;
	}
	
	@Column(name = "LOGIN_NAME",nullable=false,unique = true)
	public String getLoginName() {
		return loginName;
	}
	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}
	
	@Column(name = "PASSWORD",nullable=false)
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}	
	
	@Temporal(TemporalType.TIMESTAMP) 	//指定具体时间类型
	@Column(name = "CREATE_TIME",columnDefinition = "timestamp default CURRENT_TIMESTAMP")
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	//@Temporal(TemporalType.TIMESTAMP) 	//指定具体时间类型
	@Column(name = "LAST_LOGIN_TIME")
	public Date getLastLoginTime() {
		return lastLoginTime;
	}
	public void setLastLoginTime(Date lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}
	
	@Column(name = "LOGIN_IP")
	public String getLoginIp() {
		return loginIp;
	}
	public void setLoginIp(String loginIp) {
		this.loginIp = loginIp;
	}
	@Column(name = "STATUS",nullable = false,columnDefinition = "tinyint default 9")
	public Byte getStatus() {
		return status;
	}
	public void setStatus(Byte status) {
		this.status = status;
	}	
}
